import { request } from '../../plugin/request'

// 提交订单
export function addOrderData (param) {
  return request({
    url: '/order/add',
    method: 'post',
    data: {
      uid: param.uid,
      freight: param.freight,
      addsid: param.addsid,
      goodsData: JSON.stringify(param.goodsData)
    }
  })
}

// 获取最后订单编号
export function getOrderData (uid) {
  return request({
    url: '/order/lastordernum',
    method: 'get',
    params: {
      uid: uid
    }
  })
}

// 我的订单
export function getMyOrderData (param) {
  return request({
    url: '/user/myorder/index',
    method: 'get',
    params: {
      uid: param.uid,
      status: param.status,
      page: param.page ? param.page : 1
    }
  })
}

// 取消订单
export function cancelOrderData (param) {
  return request({
    url: '/user/myorder/clearorder',
    method: 'get',
    params: {
      uid: param.uid,
      ordernum: param.ordernum,
    }
  })
}

// 确认收货(订单)
export function sureOrderData (param) {
  return request({
    url: '/user/myorder/finalorder',
    method: 'get',
    params: {
      uid: param.uid,
      ordernum: param.ordernum,
    }
  })
}

// 会员订单详情
export function orderDetailsData (param) {
  return request({
    url: '/user/myorder/desc',
    method: 'get',
    params: {
      uid: param.uid,
      ordernum: param.ordernum,
    }
  })
}

// 待评价订单
export function getReviewOrderData (options) {
  return request({
    url: '/user/myorder/reviewOrder',
    method: 'get',
    params: {
      uid: options.uid,
      page: options.page ? options.page : 1,
    }
  })
}

// 获取评价选项
export function getReviewServiceData () {
  return request({
    url: '/home/reviews/service'
  })
}

// 提交评价
export function addReviewsData (options) {
  return request({
    url: '/home/reviews/add',
    method: 'post',
    data: {
      uid: options.uid,
      gid: options.gid,
      content: options.content,
      ordernum: options.ordernum,
      rsdata: JSON.stringify(options.rsdata)
    }
  })
}
